package com.wg.msshopsp.backendmanagement.shop.mapper;

import com.wg.msshopsp.backendmanagement.shop.entity.ProductSpecValue;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ProductSpecValueMapper {
    // 插入规格值（不需要返回ID，因为后续用不到）
    @Insert("INSERT INTO productspecvalue (spec_id, value) " +
            "VALUES (#{specId}, #{value})") // #{specId}对应ProductSpecValue的specId字段
    void insert(ProductSpecValue value);


    @Select("SELECT id AS spec_value_id, spec_id, value AS spec_value FROM productspecvalue WHERE spec_id = #{specId}")
    @Results({
            @Result(id = true, property = "id", column = "spec_value_id"), // 规格值ID（唯一标识）
            @Result(property = "specId", column = "spec_id"),
            @Result(property = "value", column = "spec_value")
    })
    List<ProductSpecValue> getValuesBySpecId(@Param("specId") Long specId);
}